<!DOCTYPE HTML>
<html lang="en">
<head>
<title>SetControlDelay - Syntax &amp; Usage | AutoHotkey</title>
<meta name="description" content="The SetControlDelay command sets the delay that will occur after each control-modifying command." />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href="../static/theme.css" rel="stylesheet" type="text/css" />
<script src="../static/content.js" type="text/javascript"></script>
</head>
<body>

<h1>SetControlDelay</h1>

<p>Sets the delay that will occur after each control-modifying command.</p>

<pre class="Syntax"><span class="func">SetControlDelay</span>, Delay</pre>
<h2>Parameters</h2>
<dl>

  <dt>Delay</dt>
  <dd><p>Time in milliseconds, which can be an <a href="../Variables.htm#Expressions">expression</a>. Use -1 for no delay at all and 0 for the smallest possible delay. If unset, the default delay is 20.</p></dd>

</dl>

<h2>Remarks</h2>
<p>A short delay (sleep) is done automatically after every Control command that changes a control, namely <a href="Control.htm">Control</a>, <a href="ControlMove.htm">ControlMove</a>, <a href="ControlClick.htm">ControlClick</a>, <a href="ControlFocus.htm">ControlFocus</a>, and <a href="ControlSetText.htm">ControlSetText</a> (<a href="ControlSend.htm">ControlSend</a> uses <a href="SetKeyDelay.htm">SetKeyDelay</a>). This is done to improve the reliability of scripts because a control sometimes needs a period of &quot;rest&quot; after being changed by one of these commands. The rest period allows it to update itself and respond to the next command that the script may attempt to send to it.</p>
<p>Although a delay of -1 (no delay at all) is allowed, it is recommended that at least 0 be used, to increase confidence that the script will run correctly even when the CPU is under load.</p>
<p>A delay of 0 internally executes a Sleep(0), which yields the remainder of the script's timeslice to any other process that may need it. If there is none, Sleep(0) will not sleep at all.</p>
<p>If the CPU is slow or under load, or if window animation is enabled, higher delay values may be needed.</p>
<p>The built-in variable <strong>A_ControlDelay</strong> contains the current setting.</p>
<p>Every newly launched <a href="../misc/Threads.htm">thread</a> (such as a <a href="../Hotkeys.htm">hotkey</a>, <a href="Menu.htm">custom menu item</a>, or <a href="SetTimer.htm">timed</a> subroutine) starts off fresh with the default setting for this command. That default may be changed by using this command in the auto-execute section (top part of the script).</p>
<h2>Related</h2>
<p><a href="Control.htm">Control</a>, <a href="ControlMove.htm">ControlMove</a>, <a href="ControlClick.htm">ControlClick</a>, <a href="ControlFocus.htm">ControlFocus</a>, <a href="ControlSetText.htm">ControlSetText</a>, <a href="SetWinDelay.htm">SetWinDelay</a>, <a href="SetKeyDelay.htm">SetKeyDelay</a>, <a href="SetMouseDelay.htm">SetMouseDelay</a>, <a href="SetBatchLines.htm">SetBatchLines</a></p>
<h2>Examples</h2>
<div class="ex" id="ExBasic">
<p><a href="#ExBasic">#1</a></p>
<pre>SetControlDelay, 0</pre>
</div>

</body>
</html>
